package barbershop.com.dao;

import barbershop.com.entity.Vip;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VipDao extends JpaRepository<Vip, Integer> {
    Vip findByVipPhonenumber(String telNumber);
    @Modifying
    @Query(value = "update vip set vip_balance=?1 where vip_id=?2",
            nativeQuery = true)
    void updateBalance(Double newBalance, Integer vipId);

    @Query(value = "select * from vip where vip_name like %?1%",
            nativeQuery = true)
    List<Vip> findVipByNameLike(String vipName);
}
